######### R version 4.1.1 (2021-08-10) -- "Kick Things"
######## [R.app GUI 1.77 (7985) aarch64-apple-darwin20]

rm(list=ls())
setwd("/Users/lee/Desktop/attachments")
library(ggplot2)
library(plyr)
library(RColorBrewer)
library(readxl)
library(readr)
require(gridExtra)
library(maptools)
library(rgdal)
library(haven)
library(scales)
library(mapproj)


Sys.setlocale(category = "LC_ALL", locale = "zh_CN")

china_map = readOGR("/Users/lee/Desktop/attachments/pro.shp")

shape <- china_map@data 
shape_frame <- data.frame(shape,id=seq(0:34)-1) 
china_map_frame <- fortify(china_map) 
china_map_data <- join(china_map_frame, shape_frame, type = 'full') 

library(readxl)
trade <- read_excel("/Users/lee/Desktop/attachments/trade.xlsx")
map_data <- join(china_map_data, trade, type = 'full')

P1<-ggplot(map_data, aes(x = long, y = lat, group = group,fill=Data))+geom_polygon(colour='grey40', size=0.2)+
  scale_fill_distiller(name="Trade Openness(as % of GDP)",palette="Greys",breaks=pretty_breaks(n=5),trans="reverse")+coord_map('polyconic')+theme(panel.grid=element_blank(),panel.background = element_blank(),axis.text = element_blank(),axis.ticks = element_blank(),axis.title = element_blank()) 
pdf('FigureA2',bg="transparent")
grid.arrange(P1, ncol=1)
dev.off()


